﻿import idv.ben.gc4flash.chart.*;
import idv.ben.gc4flash.dataLine.*;
import idv.ben.gc4flash.encode.*;
import idv.ben.gc4flash.fill.*;
import idv.ben.gc4flash.util.*;
/**
* Linear stripes 填色方式，用來填圖形的背景色，或是整張圖片的背景色<br>
* 參考 Google Chart API：<a href="http://code.google.com/apis/chart/#linear_stripes" target="_blank">http://code.google.com/apis/chart/#linear_stripes</a><br>
*/
class idv.ben.gc4flash.fill.LinearStripesFill implements IFill {
	//<bg or c> is bg for background fill or c for chart area fill.
	private var fillArea:String;
	//<angle> specifies the angle of the gradient between 0 (vertical) and 90 (horizontal).
	private var angle:Number;
	//<color> is an RRGGBB format hexadecimal number.
	//<width> must be between 0 and 1 where 1 is the full width of the chart. Stripes are repeated until the chart is filled.
	//[{color:"FFFFFF", width:1 to 0}]
	private var colorSet:Array;
	/**
	* 建構子
	* @param fillArea 填色區域：
	* 		<ul>
	*		<li>{@link idv.ben.gc4flash.fill.FillType#FILL_TYPE_BG} = "bg"</li>
	*		<li>{@link idv.ben.gc4flash.fill.FillType#FILL_TYPE_CHART} = "c"</li>
	*		</ul>
	* @param angle 角度
	* @param colorSet 顏色字串組成的陣列，["顏色1", "顏色2", ..., "顏色n"]<br>
	* 		顏色字串，請參考 Google Chart API：<a href="http://code.google.com/apis/chart/#rgb" target="_blank">http://code.google.com/apis/chart/#rgb</a>
	*/
	//chf=<bg or c>,ls,<angle>,<color 1>,<width 1>,<color n>,<width n>
	function LinearStripesFill(fillArea:String, angle:Number, colorSet:Array) {
		this.fillArea = fillArea;
		this.angle = angle;
		this.colorSet = colorSet;
	}
	/**
	* 將填色設定，組成 URL 參數字串
	* <br>
	* <img src="http://chart.apis.google.com/chart?cht=lc&chd=s:UVVUVVUUUVVUSSVVVXXYadfhjlllllllmmliigdbbZZXVVUUUTU&chco=0000FF&chls=2.0,1.0,0.0&chxt=x,y&chxl=0:|Jan|Feb|Mar|Jun|Jul|Aug|1:|0|25|50|75|100&chs=200x125&chg=100.0,25.0&chf=c,ls,0,CCCCCC,0.2,ffffff,0.2"><br>
	* chf=c,ls,0,CCCCCC,0.2,ffffff,0.2<br>
	* <br>
	* <img src="http://chart.apis.google.com/chart?cht=lc&chd=s:UVVUVVUUUVVUSSVVVXXYadfhjlllllllmmliigdbbZZXVVUUUTU&chco=0000FF&chls=2.0,1.0,0.0&chs=200x125&chxt=x,y&chxl=0:|Jan|Feb|Mar|Jun|Jul|Aug|1:|0|25|50|75|100&chg=100.0,25.0&chf=c,ls,90,999999,0.25,CCCCCC,0.25,FFFFFF,0.25"><br>
	* chf=c,ls,90,999999,0.25,CCCCCC,0.25,FFFFFF,0.25<br>
	* @return URL 參數字串
	*/
	function toChartData():String {
		var chartData:Array = new Array();
		for (var i:Number = 0; i<colorSet.length; i++) {
			chartData.push(colorSet[i].color+","+colorSet[i].width);
		}
		return fillArea+",ls,"+angle+","+chartData.join(",");
	}
}
